﻿using System;
using Cubicle.Core.Interfaces;

namespace Cubicle.Core.Repository.HandleParsers
{
    public abstract class HandleParserBase : IHandleParser
    {
        public char Prefix { get; private set; }
        protected string PrefixStr;

        public HandleParserBase(char prefix)
        {
            Prefix = prefix;
            PrefixStr = Prefix.ToString();
        }

        public abstract string KeyToHandle(string key);
        public abstract string HandleToKey(string handle);

        public event EventHandler GetEvent;
        public event EventHandler SetEvent;

        public virtual void OnGet(object sender, EventArgs args)
        {
            if (GetEvent != null) GetEvent(sender, args);
        }

        public virtual void OnSet(object sender, EventArgs args)
        {
            if (SetEvent != null) SetEvent(sender, args);
        }

    }
}
